package MultiThread;

import java.net.MalformedURLException;
import java.net.URL;
import java.util.Iterator;

public class Majneh2 {

	public static void main(String[] args) {
		try {
			long start, stop;
			start = System.currentTimeMillis();
			Spider sp;
			sp = new Spider(new URL("http://cs.lth.se/eda095/"), 2000);
			for (int i = 0; i < 10; i++) {
				(new Processor(sp)).start();
			}
			sp.isFinished();
			stop = System.currentTimeMillis();
			Iterator<URL> itr = sp.getLinks().iterator();
			System.out.println("List of URLs:");
			while (itr.hasNext()) {
				System.out.println(itr.next());
			}
			Iterator<URL> itr2 = sp.getMails().iterator();
			System.out.println("----------------------------");
			System.out.println("List of addresses:");
			while (itr2.hasNext()) {
				System.out.println(itr2.next());
			}
			System.out.println("Found 2000 links in " + (stop - start) / 1000
					+ " seconds.");
		} catch (MalformedURLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		System.exit(0);
	}
}
